]> dgit.raspbian.org Git - gnome-shell.git/commit
appDisplay: Get linear index using item instead of page and position
authorJonas Dreßler <verdre@v0yd.nl>
Fri, 24 Jun 2022 08:38:44 +0000 (10:38 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 1 Feb 2023 12:56:28 +0000 (12:56 +0000)
commitb781b3e9fd1ff248294fe656e18c86050d65d46f
tree8f1f80e3714b565b68faa4c8145659803b7a9e3e
parent95e1f760cbcad034abeb010be16c8fe4f7e427f3
appDisplay: Get linear index using item instead of page and position

_getLinearPosition() is a function that converts a page and position
index to the "accumulated" index that includes all pages before the
page. The function is used by _addItem() and _moveItem() for getting the
new index of an item inside the _orderedItems array.

Now when passing -1 as position to _addItem() or _moveItem(), this means
the item should be appended to the page. Right now _getLinearPosition()
returns the last item index on the page when passed -1, inserting the
item into _orderedItems at this index will actually not append it, but
insert it between the second last and last item.

To fix it, let's make the whole thing more robust by explicitly passing
an item to _getLinearPosition(). This means we simply no longer have to
assume what "-1" means. Moving the call to _getLinearPosition() to
happen after addItem() and moveItem() ensures that the new item position
is used and not the old one.

This fixes issues where the _orderedItems array gets out of order when
moving or adding items.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2348>
js/ui/appDisplay.js